package org.misalen.web.database.repository.mysql;

import org.hibernate.Query;
import org.hibernate.Session;
import org.misalen.web.database.dao.mysql.impl.BaseMySqlDaoImpl;
import org.misalen.web.database.model.mysql.sys.SysAdminRole;
import org.springframework.stereotype.Repository;

@Repository
public class SysAdminRoleRepository extends BaseMySqlDaoImpl<SysAdminRole> {

	public SysAdminRole getByAdmin(String adminId) {
		return get("from SysAdminRole where adminId=?0", new Object[] { adminId });
	}

	public void deleteByAdmin(String adminId) {
		Session session = this.openSession();
		Query query = session.createQuery("delete SysAdminRole where adminId='" + adminId + "'");
		query.executeUpdate();
		closeSession(session);
	}

}